package drds.binlog.parse.driver.socket;

import java.net.Socket;
import java.net.SocketAddress;

/**
 * 实现channel的管理（监听连接、读数据、回收）
 */
public abstract class BioSocketChannels
{

    public static BioSocketChannel open(SocketAddress socketAddress) throws Exception
    {
        Socket socket = new Socket();
        socket.setSoTimeout(BioSocketChannel.SO_TIMEOUT);
        socket.setTcpNoDelay(true);
        socket.setKeepAlive(true);
        socket.setReuseAddress(true);
        socket.connect(socketAddress, BioSocketChannel.DEFAULT_CONNECT_TIMEOUT);
        return new BioSocketChannel(socket);
    }

}
